import threading

lock = threading.Lock()


def do_something():
    lock.acquire()
    # 临界区：执行需要保护的操作
    lock.release()
